<?php
namespace Model;
use Think\Model;

//此处为公共类
class TempUserModel extends Model {
//    检验验证码
    public function checkAuthCode($user_account, $auth_code) {
	//查询验证码是否正确
//	dump($user_account);	dump($auth_code);

	$data = M('temp_user');
	$condition['temp_user_tel'] = $user_account;
	$condition['temp_user_authcode'] = $auth_code;
	$info = $data->where($condition)->select();
//	dump($info);
	//若无法匹配验证码，则返回false
	if(!$info) {
//	    echo "验证码有误, 测试代码1";
	    return false;
	}
//	dump($info);
	//判断验证码是否在有效期内
	$authCodeTime = strtotime($info[0]['temp_user_authcode_time']);
	$currentTime = strtotime('now');
	$s = $currentTime - $authCodeTime;
	//验证码时间为2分钟（120）秒，超过则无效
	if($s > 300){
//	    echo "验证码无效，测试代码2";
	    return false;
	}else
	    return true;
    }
}